package com.ict.web.controller.yzq;

import com.ict.common.annotation.Log;
import com.ict.common.core.controller.BaseController;
import com.ict.common.core.domain.AjaxResult;
import com.ict.common.core.page.TableDataInfo;
import com.ict.common.enums.BusinessType;
import com.ict.common.utils.poi.ExcelUtil;
import com.ict.web.domain.Finance;
import com.ict.web.dto.FinanceAddDto;
import com.ict.web.service.IFinanceService;
import com.ict.web.vo.FinanceVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 发改/财政局审批结果备案--刘杰Controller
 *
 * @author ruoyi
 * @date 2022-03-01
 */
@Api(tags = "发改-财政局审批结果备案")
@RestController
@RequestMapping("/finance")
public class FinanceController extends BaseController
{
    @Autowired
    private IFinanceService financeService;

    /**
     * 查询发改/财政局审批结果备案--刘杰列表
     */
//    @PreAuthorize("@ss.hasPermi('web:finance:list')")
    @GetMapping("/list")
    @ApiOperation("查询发改/财政局审批结果备案")
    public TableDataInfo list(Finance finance)
    {
        startPage();
        List<Finance> list = financeService.selectFinanceList(finance);
        return getDataTable(list);
    }

    /**
     * 导出发改/财政局审批结果备案--刘杰列表
     */
//    @PreAuthorize("@ss.hasPermi('web:finance:export')")
    @Log(title = "发改/财政局审批结果备案--刘杰", businessType = BusinessType.EXPORT)
    @ApiOperation("导出发改/财政局审批结果备案")
    @PostMapping("/export")
    public void export(HttpServletResponse response, Finance finance)
    {
        List<Finance> list = financeService.selectFinanceList(finance);
        ExcelUtil<Finance> util = new ExcelUtil<Finance>(Finance.class);
        util.exportExcel(response, list, "发改/财政局审批结果备案--刘杰数据");
    }

    /**
     * 获取发改/财政局审批结果备案--刘杰详细信息
     */
//    @PreAuthorize("@ss.hasPermi('web:finance:query')")
    @ApiOperation("获取发改/财政局审批结果备案")
    @GetMapping(value = "/{financeId}")
    public FinanceVo getInfo(@PathVariable("financeId") Long financeId)
    {
        return financeService.selectFinanceByFinanceId(financeId);
    }

    /**
     * 新增发改/财政局审批结果备案--刘杰
     */
//    @PreAuthorize("@ss.hasPermi('web:finance:add')")
    @Log(title = "发改/财政局审批结果备案--刘杰", businessType = BusinessType.INSERT)
    @ApiOperation("新增发改/财政局审批结果备案")
    @PostMapping
    public Long add(@RequestBody FinanceAddDto dto)
    {
        return financeService.insertFinance(dto);
    }

    /**
     * 修改发改/财政局审批结果备案--刘杰
     */
//    @PreAuthorize("@ss.hasPermi('web:finance:edit')")
    @Log(title = "发改/财政局审批结果备案--刘杰", businessType = BusinessType.UPDATE)
    @ApiOperation("修改发改/财政局审批结果备案")
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody FinanceAddDto dto)
    {
        return toAjax(financeService.updateFinance(dto));
    }

    /**
     * 删除发改/财政局审批结果备案--刘杰
     */
//    @PreAuthorize("@ss.hasPermi('web:finance:remove')")
    @Log(title = "发改/财政局审批结果备案--刘杰", businessType = BusinessType.DELETE)
    @ApiOperation("删除发改/财政局审批结果备案")
	@DeleteMapping("/{financeId}")
    public AjaxResult remove(@PathVariable Long financeId)
    {
        return toAjax(financeService.deleteFinanceByFinanceId(financeId));
    }
}
